https://codeforces.com/profile/wowoto
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<bitset>
#include<stack>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<assert.h>
using namespace std;
typedef long long ll;
ll N = 2e5 + 1,M=5e5, mod = 998244353, MOD = 1e9 + 7;
struct Data {
	int _val, _l, _r;
	Data(int val=0, int l=0, int r=0) {
		_val = val; _l = l; _r = r;
	}
};
ll solve() {
	ll n; cin >> n;
	vector<int> t(n),ans(n);
	vector<Data> p;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < n; i++) {
		if (p.empty() || p.back()._val != t[i]) {
			p.push_back({ t[i],i,i });
		}
		else {
			p.back()._r=i;
		}
	}
	int sz = p.size(), c = 0;
	for (auto e: p) {
		int x = e._val, l = e._l, r = e._r;
		sz--;
		while (l <= r) {
			ans[l] = c&1;
			l++;
		}
		c++;
		if ((sz & 1) != (c & 1) && e._r > e._l) {
			ans[r] = c&1;
			c++;
		}
	}
	for (int i = 0; i < 3; i++) {
		if (t[n - 2] != t[n - 1] && ans[n - 2] == i) {
			continue;
		}
		if (t[0] != t[n - 1] && ans[0] == i) {
			continue;
		}
		ans[n - 1] = i;
		break;
	}
	vector<int> cnt(3);
	int k = 0;
	for (int i = 0; i < n; i++) {
		cnt[ans[i]] = 1;
		ans[i]++;
	}
	for (int i = 0; i < 3; i++) {
		k += cnt[i];
	}
	cout << k << endl;
	for (int i = 0; i < n; i++) {
		cout << ans[i] << ' ';
	}
	cout << endl;
	return 0;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1; cin >> t;
	while (t--) {
		//int t1 = clock();
		ll ans = solve();
		//int t2 = clock();
		//cout << "t:" << t2 - t1 << endl;
		//cout << ans << endl;
	}
	return 0;
}